
package urbanparks;

import java.util.LinkedList;
import java.util.List;

/**
 * A class to store volunteer information.
 * 
 * @author Dallas Rosson
 * @version 1.0 2/22/2012
 */
public class Volunteer extends User {

  /**
   * The Volunteer's contact numbers.
   */
  List<String> my_contact_numbers =
      new LinkedList<String>();

  /**
   * The user's blackball status. <br>
   * True = blackballed. <br>
   * False = not blackballed.
   */
  private boolean my_blackball_status = false;

  // Constructor

  /**
   * Creates a new volunteer.
   * 
   * @param the_first_name The user's first name.
   * @param the_last_name The user's last name.
   * @param the_email The user's email address.
   * @param the_permission_level The user's permission
   *          level.
   * @param the_contact_number The Volunteer's first contact
   *          number.
   * @param the_bb_status The blackball status.
   */
  public Volunteer(final String the_first_name,
      final String the_last_name, final String the_email,
      final int the_permission_level,
      final String the_contact_number, boolean the_bb_status) {

    setFirstName(the_first_name);
    setLastName(the_last_name);
    setEmailAddress(the_email);
    setPermissionLevel(the_permission_level);
    my_contact_numbers.add(the_contact_number);

    if (the_bb_status == true) {

      blackball();

    }

  }

  /**
   * Creates a new volunteer.
   * 
   * @param the_first_name The user's first name.
   * @param the_last_name The user's last name.
   * @param the_email The user's email address.
   * @param the_permission_level The user's permission
   *          level.
   * @param the_contact_numbers A list of the Volunteer's
   *          first contact numbers.
   * @param the_bb_status The blackball status.
   */
  public Volunteer(final String the_first_name,
      final String the_last_name, final String the_email,
      final int the_permission_level,
      final List<String> the_contact_numbers,
      boolean the_bb_status) {

    setFirstName(the_first_name);
    setLastName(the_last_name);
    setEmailAddress(the_email);
    setPermissionLevel(the_permission_level);
    my_contact_numbers.addAll(the_contact_numbers);

    if (the_bb_status == true) {

      blackball();

    }

  }

  // Setters

  /**
   * Adds a phone number to the volunteers contact numbers
   * list.
   */
  public void addContactNumber(final String the_number) {

    my_contact_numbers.add(the_number);

  }

  /**
   * Sets the user's blackballed status to TRUE.
   */
  public void blackball() {

    my_blackball_status = true;

  }

  // Getters

  /**
   * @return A list containing the volunteer's contact
   *         numbers.
   */
  public String getContactNumber() {

    return my_contact_numbers.get(my_contact_numbers.size() - 1);

  }

  /**
   * @return The user's blackballed status.
   */
  public boolean isBlackballed() {

    return my_blackball_status;

  }
  
  /**
   * Returns Valunteer class string, CSV:
   * First, Last, Email, Permission, Number, Blackballed
   */
  public String getFileString(){
    StringBuilder sb = new StringBuilder();
    final char c = ',';
    sb.append(getFirstName());
    sb.append(c);
    sb.append(getLastName());
    sb.append(c);
    sb.append(getEmailAddress());
    sb.append(c);
    sb.append(getPermissionLevel());
    sb.append(c);
    sb.append(my_contact_numbers.get(0));
    sb.append(c);
    sb.append(isBlackballed());
    return sb.toString();
  }
}
